package me.huanmeng.heater.http;

import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpUtil;

/**
 * 2021/9/26<br>
 * Heater<br>
 * 开黑啦请求API
 *
 * @author huanmeng_qwq
 */
@SuppressWarnings("unused")
public class KaiheilaApi {
    public static final int VERSION = 3;
    public static final String BASE_URL = "https://www.kaiheila.cn/api/v" + VERSION;
    private final String token;

    public KaiheilaApi(String token) {
        this.token = token;
    }

    public HttpRequest doGet(String url) {
        if (!url.startsWith("/")) {
            url = "/" + url;
        }
        return HttpUtil.createGet(BASE_URL + url).header("Authorization", "Bot " + token)
                .timeout(5000);
    }

    public HttpRequest doPost(String url) {
        if (!url.startsWith("/")) {
            url = "/" + url;
        }
        return HttpUtil.createPost(BASE_URL + url).header("Authorization", "Bot " + token)
                .timeout(5000);
    }
}
